﻿/*----------------------------------------------------------------
    // Copyright (C) 2009 江苏华招网
    // 版权所有。 
    // 作者：马毅
    //
    // 文件名：OrderConfirm.cs
    // 文件功能描述：退货详情
    // 创建标识：马毅2009-05-19
    //
    // 修改标识： 
    // 修改描述： 
    //
    // 修改标识： 
    // 修改描述： 
    //
    // 审核人： 
    // 审核时间： 
    // 审核说明： 
 //----------------------------------------------------------------*/
using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HZ.DrugTrade.Web;
using HZ.DrugTrade.Model;
using HZ.DrugTrade.IBLL;
using HZ.DrugTrade.BLLFactory;
using HZ.DrugTrade.Model.Enum;
namespace HZ.DrugTrade.Web.Hospitals.SalesReturn
{
    public partial class RetrunGoodsOderdetail : BasePage
    {
        public RetrunGoodsOderdetail()
        {
            this.ModuleNo = Module.退货单管理.ToString();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!HZ.DrugTrade.Web.Function.IsThreeLevel())//项目查询条件仅三级医院可见
            {
                this.ddlProjectid.Visible = false;
                this.lblProjectid.Visible = false;
            }
            if (!Page.IsPostBack)
            {
                banding();
            }
        }
        /// <summary>
        /// 绑定
        /// </summary>
        private void banding()
        {
            IBLL_Purchase IBLLP = Factory.BLL_Purchase();
            HZ.DrugTrade.Model.Query.ReturnMerchandiseDetail aReturnMerchandiseDetail = new HZ.DrugTrade.Model.Query.ReturnMerchandiseDetail();
            aReturnMerchandiseDetail.HospitalID = CurrentAccount.GetUser().Org.OrgID;
            //2009-11-26
            aReturnMerchandiseDetail.GoodsName = txtGoodsName.Text;
            aReturnMerchandiseDetail.Outlookc = txtOutLookc.Text;
            aReturnMerchandiseDetail.PinyinCode = this.txtpinyincode.Text.Trim();
            aReturnMerchandiseDetail.Material = txtMaterial.Text;
            aReturnMerchandiseDetail.CompanyName = txtCompanyName_PS.Text;
            aReturnMerchandiseDetail.ReturnName = txtReturnName.Text;
            aReturnMerchandiseDetail.SortFields = "ReturnTime desc";
            //aReturnMerchandiseDetail.ProjectID = this.ddlProjectid.SelectedValue;
            if (this.ddlProjectid.Visible != false)
            {
                aReturnMerchandiseDetail.ProjectID = this.ddlProjectid.SelectedValue;
            }
            else
            {
                aReturnMerchandiseDetail.ProjectID = "0001";
            }
            switch (ddlstatud.SelectedItem.Text.Trim())
            {
                case "全部"://(0未确认， 1确认 2拒绝)
                    break;
                case "未处理":
                    aReturnMerchandiseDetail.ReturnState = 0;
                    break;
                case "已确认":
                    aReturnMerchandiseDetail.ReturnState = 1;
                    break;
                case "拒绝":
                    aReturnMerchandiseDetail.ReturnState = 2;
                    break;
            }
            //AspNetPager1.PageSize = Constants.GRIDVIEW_PAGE_SIZE;
            int totalCount = 0;
            gvwReturngoods.PageSize = AspNetPager1.PageSize;
            gvwReturngoods.DataSource = IBLLP.GetReturnReturnMerchandiseDetail(aReturnMerchandiseDetail, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalCount);
            gvwReturngoods.DataBind();
            AspNetPager1.RecordCount = totalCount;
        }
        /// <summary>
        /// 翻页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void AspNetPager1_OnPageChanged(object sender, EventArgs e)
        {
            banding();
        }

        protected void btnQuery_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
            banding();
        }

        protected void lbnSwitch_Click(object sender, EventArgs e)
        {
            if (lbnSwitch.CommandArgument == "simple")
            {
                ltlAdvance.Text = "";
                lbnSwitch.CommandArgument = "advance";
                lbnSwitch.Text = "简单查询";
            }
            else
            {
                ltlAdvance.Text = "<tbody id='advance' style='display:none'>";
                lbnSwitch.CommandArgument = "simple";
                lbnSwitch.Text = "高级查询";

                //清空数据
                txtReturnName.Text = "";
                txtCompanyName_PS.Text = "";
                //txtStartDate.Text = "";
                //txtEndDate.Text = "";
                //txtPlanTimeFrom.Text = "";
                //txtPlanTimeTo.Text = "";
                //txtStartTimeFrom.Text = "";
                //txtStartTimeTo.Text = "";
            }
        }




        public string Getstaus(object stratus)
        {
            return "display='display'";
        }
        /// <summary>
        /// 导出2009-11-26
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnExport_Click(object sender, EventArgs e)
        {
            IBLL_Purchase IBLLP = Factory.BLL_Purchase();
            HZ.DrugTrade.Model.Query.ReturnMerchandiseDetail aReturnMerchandiseDetail = new HZ.DrugTrade.Model.Query.ReturnMerchandiseDetail();
            aReturnMerchandiseDetail.HospitalID = CurrentAccount.GetUser().Org.OrgID;
            aReturnMerchandiseDetail.GoodsName = txtGoodsName.Text;
            aReturnMerchandiseDetail.Outlookc = txtOutLookc.Text;
            aReturnMerchandiseDetail.PinyinCode = this.txtpinyincode.Text.Trim();
            aReturnMerchandiseDetail.Material = txtMaterial.Text;
            aReturnMerchandiseDetail.CompanyName = txtCompanyName_PS.Text;
            aReturnMerchandiseDetail.ReturnName = txtReturnName.Text;
            aReturnMerchandiseDetail.SortFields = "ReturnTime desc";
            //aReturnMerchandiseDetail.ProjectID = this.ddlProjectid.SelectedValue;
            if (this.ddlProjectid.Visible != false)
            {
                aReturnMerchandiseDetail.ProjectID = this.ddlProjectid.SelectedValue;
            }
            else
            {
                aReturnMerchandiseDetail.ProjectID = "0001";
            }
            switch (ddlstatud.SelectedItem.Text.Trim())
            {
                case "全部"://(0未确认， 1确认 2拒绝)
                    break;
                case "未处理":
                    aReturnMerchandiseDetail.ReturnState = 0;
                    break;
                case "已确认":
                    aReturnMerchandiseDetail.ReturnState = 1;
                    break;
                case "拒绝":
                    aReturnMerchandiseDetail.ReturnState = 2;
                    break;
            }

            int totalCount = 0;

            IList<Model.View.ReturnMerchandiseDetail> ReturnMerchandiseDetailList = IBLLP.GetReturnReturnMerchandiseDetail(aReturnMerchandiseDetail, 1, 0, out totalCount);

            System.Data.DataTable dt = HZ.Data.ModelConvert.GetDataTableFromModel(ReturnMerchandiseDetailList);
            HZ.Excel.ExcelHelper.ExportDataForWeb(dt, gvwReturngoods);

        }
    }
}
